package cn.xaut.XAUT迎春杯预热;

import java.util.Scanner;

/**
 * G - ProjectEuler 2
 * 考点：动态规划
 */
public class demoG {

    static int helper(int n, int[] dp) {
        int sum = 0;
        for (int x : dp) {
            if (x > n)
                break;
            if (x % 2 == 0)
                sum += x;
        }
        return sum;
    }
    
    static final int N = 4000000;
    
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int T = input.nextInt();
        int[] dp = new int[N + 1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 2; i <= N; i++) 
            dp[i] = dp[i - 1] + dp[i - 2];
        for (int i = 0; i < T; i++) {
            int n = input.nextInt();
            System.out.println(helper(n, dp));
        }
    }
}
